package com.ydx.meituan.utils;

import org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorContextImpl;
import org.hibernate.validator.internal.engine.constraintvalidation.ConstraintViolationCreationContext;
import org.hibernate.validator.internal.engine.path.NodeImpl;
import org.hibernate.validator.internal.engine.path.PathImpl;
import javax.validation.ConstraintValidatorContext;
import java.util.List;

public class ParamsCheckUtil {

    public static String getParamsName(ConstraintValidatorContext constraintValidatorContext){
        ConstraintValidatorContextImpl impl=(ConstraintValidatorContextImpl) constraintValidatorContext;
        List<ConstraintViolationCreationContext> constraintViolationCreationContexts = impl.getConstraintViolationCreationContexts();
        ConstraintViolationCreationContext c = constraintViolationCreationContexts.get(0);
        PathImpl path = c.getPath();
        NodeImpl leafNode = path.getLeafNode();
        return leafNode.getName();
    }

}
